using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace teste.Models.Mapping
{
    public class GARAGEMMap : EntityTypeConfiguration<GARAGEM>
    {
        public GARAGEMMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Nome)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.CNPJ)
                .IsRequired()
                .HasMaxLength(18);

            this.Property(t => t.InscricaoMunicipal)
                .IsRequired()
                .HasMaxLength(40);

            // Table & Column Mappings
            this.ToTable("GARAGEM");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.Nome).HasColumnName("Nome");
            this.Property(t => t.CNPJ).HasColumnName("CNPJ");
            this.Property(t => t.InscricaoMunicipal).HasColumnName("InscricaoMunicipal");
            this.Property(t => t.Endereco_Id).HasColumnName("Endereco_Id");

            // Relationships
            this.HasOptional(t => t.ENDERECO)
                .WithMany(t => t.GARAGEMs)
                .HasForeignKey(d => d.Endereco_Id);

        }
    }
}
